<template>
  <div id="supervisionInformation" class="app-container">
    <div class="tabs">
      <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="竣工测绘" name="1"></el-tab-pane>
        <el-tab-pane label="初审信息" name="2"></el-tab-pane>
      </el-tabs>
    </div>
    <el-form
        :inline="true"
        label-position="right"
        label-width="90px"
        class="demo-form-inline"
      >
        <el-form-item label="权利人姓名">
          <el-input style="width: 200px;" v-model="listQuery.applicantName" placeholder="" class="filter-item" />
        </el-form-item>
        <el-form-item label="复垦片块">
          <el-select clearable style="width: 200px;" v-model="listQuery.landId" placeholder="请选择">
            <el-option
              v-for="item in selectData"
              :key="item.landId"
              :label="item.landName"
              :value="item.landId">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="开始时间">
          <el-date-picker
            value-format="yyyy-MM-dd HH:mm:ss"
            style="width: 200px;"
            v-model="listQuery.startTime"
            type="date"
            placeholder="开始时间"
            class="filter-item">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="截止时间">
          <el-date-picker
            value-format="yyyy-MM-dd HH:mm:ss"
            style="width: 200px;"
            v-model="listQuery.endTime"
            type="date"
            placeholder="截止时间"
            class="filter-item">
          </el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button @click="searchData" type="primary">查询</el-button>
        </el-form-item>
      </el-form>
    <!-- <div class="filter-container">
      <el-button class="filter-item" type="primary" icon="el-icon-edit">添加</el-button>
      <el-button class="filter-item" style="margin-left: 10px;" type="danger">删除所选</el-button>
    </div> -->

    <el-table v-if="activeName == '1'" :header-cell-style="{background:'#f9f9f9',color:'#606266'}" v-loading="listLoading" :data="list" element-loading-text="Loading" border fit highlight-current-row>
      <el-table-column type="index" align="center" label="序号" width="120">
      </el-table-column>
      <el-table-column label="权利人" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.applicantName }}</span>
        </template>
      </el-table-column>
      <el-table-column label="复垦片块" align="center">
        <template slot-scope="scope">{{ scope.row.landName }}</template>
      </el-table-column>
     <el-table-column label="竣工测绘时间" align="center">
        <template slot-scope="scope">{{ scope.row.time }}</template>
      </el-table-column>
      <el-table-column label="位置" align="center">
        <template slot-scope="scope">{{ scope.row.place }}</template>
      </el-table-column>
      <el-table-column
        fixed="right"
        label="操作"
        width="100">
        <template slot-scope="scope">
          <el-button type="text" v-if="scope.row.time" @click="toSee(scope.row,1)" size="small">查看</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-table v-if="activeName == '2'" :header-cell-style="{background:'#f9f9f9',color:'#606266'}" v-loading="listLoading" :data="list" element-loading-text="Loading" border fit highlight-current-row>
      <el-table-column type="index" align="center" label="序号" width="80">
      </el-table-column>
      <el-table-column label="权利人" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.applicantName }}</span>
        </template>
      </el-table-column>
      <el-table-column label="复垦片块" align="center">
        <template slot-scope="scope">{{ scope.row.landName }}</template>
      </el-table-column>
     <el-table-column label="竣工初审时间" align="center" width="200">
        <template slot-scope="scope">{{ scope.row.time }}</template>
      </el-table-column>
      <el-table-column label="位置" align="center" width="200">
        <template slot-scope="scope">{{ scope.row.place }}</template>
      </el-table-column>
      <el-table-column label="复垦点坐标是否准确" width="180" align="center">
        <template slot-scope="scope">{{ scope.row.ifDonateRight?(scope.row.ifDonateRight=="YES"?'是':'否'):'' }}</template>
      </el-table-column>
      <el-table-column label="测绘成果与实地是否一致" width="180" align="center">
        <template slot-scope="scope">{{ scope.row.ifResultRight?(scope.row.ifResultRight=="YES"?'是':'否'):'' }}</template>
      </el-table-column>
      <el-table-column label="主体房屋是否已复垦" width="180" align="center">
        <template slot-scope="scope">{{ scope.row.ifztfw?(scope.row.ifztfw=="YES"?'是':'否'):'' }}</template>
      </el-table-column>
      <el-table-column label="实施范围是否与现场一致" width="180" align="center">
        <template slot-scope="scope">{{ scope.row.ifssfw?(scope.row.ifssfw=="YES"?'是':'否'):'' }}</template>
      </el-table-column>
      <el-table-column label="工程位置是否准确" width="180" align="center">
        <template slot-scope="scope">{{ scope.row.ifgcwz?(scope.row.ifgcwz=="YES"?'是':'否'):'' }}</template>
      </el-table-column>
      <el-table-column label="复垦后照片能否反映现状" width="180" align="center">
        <template slot-scope="scope">{{ scope.row.iffyxz?(scope.row.iffyxz=="YES"?'是':'否'):'' }}</template>
      </el-table-column>
      <el-table-column label="工程量标注是否准确" width="180" align="center">
        <template slot-scope="scope">{{ scope.row.ifgclbz?(scope.row.ifgclbz=="YES"?'是':'否'):'' }}</template>
      </el-table-column>
      <el-table-column
        fixed="right"
        label="操作"
        width="100">
        <template slot-scope="scope">
          <el-button type="text" v-if="scope.row.time" @click="toSee(scope.row,2)" size="small">查看</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination style="margin-top:20px;text-align:center"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="listQuery.page"
      :page-sizes="[10, 15, 20, 25]"
      :page-size="listQuery.size"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total">
    </el-pagination>
  </div>
</template>

<script>
import { supervisingInfo,laterSupervisingInfo,chushenData } from "@/api/jjgc";

export default {
  filters: {
    statusFilter(status) {
      const statusMap = {
        published: "success",
        draft: "gray",
        deleted: "danger"
      };
      return statusMap[status];
    }
  },
  data() {
    return {
      activeName: '1',
      list: null,
      listLoading: true,
      listQuery: {
        page: 1,
        size: 10,
        projectId:localStorage.getItem("projectId"),
        landId:'',
        applicantName: "",
        startTime:'',
        endTime:'',
      },
      total:0, //总数
      selectData:[], //选择框
    };
  },
  created() {
    this.getData()
    this.getDataForSelect()
  },
  methods: {
    //搜索
    searchData(){
      if(this.activeName == '1'){
        this.getData()
      }else{
        this.getData1()
      }
    },
    //前往查看
    toSee(row,type){
      console.log(row)
      var sendData={}
      if(this.activeName == '2'){
        sendData = {
          vcr:row.vcr,
          photo:row.photo,
          id:row.landId,
          type:type,
        }
      }else{
        sendData = {
          id:row.landId,
          type:type,
        }
      }
      this.$router.push({
        path:'/jjgc/supervisionInformation/detail',
        query:sendData
      })
      localStorage.setItem("zongheItem",JSON.stringify(row))
    },
    getData1ForSelect(){
      var data={
        page:1,
        size:99999,
        projectId:localStorage.getItem("projectId")
      }
      chushenData(data).then(res=>{
        console.log(res)
        this.selectData=res.data.rows
      })
    },
    getData1(){
      this.listLoading=true
      var data={}
      var objArr=this.listQuery
      for (var index in objArr) {
        if(objArr[index]!=''&&objArr[index]!=null){
          data[index]=objArr[index];
        }
      }
      data['startTime']=this.listQuery.startTime
      data['stopTime']=this.listQuery.endTime
      chushenData(data).then(res=>{
        console.log(res)
        this.list=res.data.rows
        this.total=res.data.total
        this.listLoading=false
      }).catch(error=>{
        this.listLoading=false
      })
    },
    getDataForSelect(){
      var data={
        page:1,
        size:99999,
        projectId:localStorage.getItem("projectId")
      }
      laterSupervisingInfo(data).then(res=>{
        console.log(res)
        this.selectData=res.data.rows
      })
    },
    getData(){
      this.listLoading=true
      var data={}
      var objArr=this.listQuery
      for (var index in objArr) {
        if(objArr[index]!=''&&objArr[index]!=null){
          data[index]=objArr[index];
        }
      }
      data['startTime']=this.listQuery.startTime
      data['stopTime']=this.listQuery.endTime
      laterSupervisingInfo(data).then(res=>{
        console.log(res)
        this.list=res.data.rows
        this.total=res.data.total
        this.listLoading=false
      }).catch(error=>{
        this.listLoading=false
      })
    },
    //改变每页显示条数
    handleSizeChange(e){
      console.log(e)
      this.listQuery.size=e
      if(this.activeName == '1'){
        this.getData()
      }else{
        this.getData1()
      }
    },
    //改变页码
    handleCurrentChange(num){
      console.log(num)
      this.listQuery.page=num
      if(this.activeName == '1'){
        this.getData()
      }else{
        this.getData1()
      }
    },
    handleClick(tab, event) {
      this.listQuery={
        page: 1,
        size: 10,
        projectId:localStorage.getItem("projectId"),
        landId:'',
        applicantName: "",
        startTime:'',
        endTime:'',
      }
      if(this.activeName=="1"){
        this.getData()
      }else{
        this.getData1()
      }
    }
  }
};
</script>
<style lang="scss" scoped>
#supervisionInformation /deep/ .el-tabs__nav-wrap::after{
  height: 1px;
}
</style>
